#pragma once
#include "../Ode.h"

namespace Skill
{
	namespace Ode
	{
		ref class DSurfaceParameters;
		ref class DContactGeom;
		ref class DVector3;

		/// <summary> contact info used by contact joint </summary>
		public ref class DContactInfo : DIUnmanagedPointer
		{
			INTERNAL_CLASS_DECLARATION_NO_FINALIZE(DContactInfo,dContact);
		public:
			UNMANAGEDPOINTER_DECLARATION();

			static VALUE_PROP_DECLARATION_GET(int,SizeInBytes);

			!DContactInfo()
			{
				if(_Free && _This)
					delete _This;
				_This = nullptr;
				_Free = false;
				_Disposed = true;
			}
			DContactInfo()
			{
				_SetPointer(new dContact(),true);
			}

			REF_PROP_DECLARATION_GETSET(DSurfaceParameters,Surface);
			REF_PROP_DECLARATION_GET(DContactGeom,Geom);			
			REF_PROP_DECLARATION_GETSET(DVector3,FDirection1);
		} ;

		public ref class DContactInfoArray : DIUnmanagedPointer
		{
			INTERNAL_CLASS_DECLARATION_NO_FINALIZE(DContactInfoArray,dContact);
		private:
			array<DContactInfo^>^ _Array;
		public:
			UNMANAGEDPOINTER_DECLARATION();

			!DContactInfoArray()
			{
				if(_Free && _This)
					delete[] _This;
				_This = nullptr;
				_Free = false;
				_Disposed = true;
			}
			DContactInfoArray(int length)
			{					
				_SetPointer(new dContact[length](),true);
				_Array = gcnew array<DContactInfo^>(length);
				for(int i=0;i<length;i++)
				{	
					_Array[i] = gcnew DContactInfo(&_This[i]);
				}
			}

			VALUE_PROP_DECLARATION_GET(int,Length);

			property DContactInfo^ default[int]
			{
				DContactInfo^ get(int index) { return _Array[index]; }
			}
		};		

	}
}